import { Mt } from '../mt'
import { DcsEntity, DcsInfo, DcsModel } from './interface'
/**  排序 权重 */
export function getWeight(mt: DcsEntity) {
	let weight = 0
	if (!!mt.apply) {
		weight += 100
	}
	if (!!mt.dcs_oper) {
		weight += 10
	}
	if (!!mt.online) {
		weight += 1
	}
	return weight
}
export const transDcsModel = (mt: DcsEntity): DcsModel => {
	let mcc = new Mt(mt)
	return {
		mcc,
		dcs: {
			isApply: !!mt.apply,
			isDcs: !!mt.dcs_oper,
			enableDcs: !!mt.enable_dcs,
		},
		attr: {
			weight: getWeight(mt),
		},
		status: {
			isChecked: false,
			isMatchSearch: true,
			isCalling: false,
		},
		mtKey: mt.mt_key,
	}
}
export function transDcsInfo(p: DcsInfo) {
	return {
		mts: p.dcs_members,
		dcsMode: p.mode,
	}
}
